import formJs from "./regexDetail.js"; //新增弹框配置项
import publicForm from "@/components/public/el-form.vue"; //弹框form

// import myCharts from "@/components/intelligentMaintenanceManage/temperatureHumidity/echarts.vue";
// import TableData from "@/components/public/el-table-pagination"; //主页面列表
//主页面列表
// import publicForm from "@/components/materialDataManage/fromCom.vue"; //弹框form
import {
    getEntryDetailsList, //详情

} from "@/api/request.js";
export default {
    props: [
        "dialogVisible",
        "dialogTitle",
        "statusNum",
        "currentRow",
        "fCompanyid",
        "fCompanyname"
    ],
    data() {
        return {
            visible: "",
            loadings: false,
            title: "进场称重材料台账",
            isLock: false,
            loading: false,
            tableData: [],
            searchObj: formJs.searchObj, //搜索条件
            table_config: formJs.table_config, //列表
            queryCriteriaData: {}, //分页
            dialogHeight: null,
            activeIndex: "1",
            formObj: formJs.formObj,
            additionalObj: formJs.additionalObj,
            isEdit: false,
            currntData: null,
            dataInfo: null,
            startDates: null,
            treeData: [], //材料种类
            getList: {
                taskNumber: "", //该数据的设备编号(必传)
                startDates: "", //开始时间(必传) 精确到秒  一般传当前时间的前40分钟
                endDates: "", //结束时间(必传）一般传当前时间的前40分钟
                page: 1, //当前页码
                pageSize: 15, //每页显示条数
                timeDates: null
            },
            formData: null,
            formDatafileList: [], //工作计划资料
            btnShow: true,
            currentDetail: null,
            selectPostionObj: [],
            types: [],
            // 材料弹框
            materialRow: {},
           
            chartsData: null,
            fCompanynames: null,
            fCompanyids: null,
            fFileurllist: [], //附件
            enterPhoto:[],//进场照片
            leavePhoto:[],//出场照片
            // inspectionForm:[],//报验单附件
        };
    },
    components: {
        publicForm,
        // myCharts,
        // TableData
    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        dialogTitle: {
            handler(newVal) {
                if (newVal) {
                    this.title = newVal;
                }
            },
            immediate: true,
        },
        statusNum: {
            handler(newVal) {
                if (newVal) {
                    this.edit(newVal);
                }
            },
            immediate: true,
        },

        currentRow: {
            handler(newVal) {
                if (newVal) {
                    console.log(newVal);
                    this.currentDetail = newVal;
                    // this.getList.taskNumber = newVal.fDeviceencode
                    // this.getList.startDates = this.common.day(0) + " " + "00:00:00"
                    // this.getList.endDates = this.common.day(0) + " " + "23:59:59"
                    // this.getList.timeDates = this.common.day(0)
                    // this.getDetail(this.getList)
                    this.getDetail({fId:this.currentDetail.gcddId})
                }
            },
            immediate: true,
        },
        fCompanyid: {
            handler(newVal) {
                if (newVal) {
                    this.fCompanyids = newVal
                }
            },
            immediate: true,
        },
        fCompanyname: {
            handler(newVal) {
                if (newVal) {
                    this.fCompanynames = newVal
                }
            },
            immediate: true,
        },
    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();
    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("GxBack-userInfo"));
        this.btnShow = true
        if (this.statusNum == 7) { //查看
            this.btnShow = false
            this.formObj.map((item) => {
                item.disabled = true;
            });
        }
        this.getHeight();
    },
    methods: {
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 0.76 + "px";
        },
        handleSelect(key) {
            this.activeIndex = key;
        },
        closeDialog() {
            this.$emit("close");
        },
 
        edit() {
            this.formData = this.$options.data.call(this).formData;
        },
      
        // 详情
        getDetail(obj) {
            getEntryDetailsList(obj).then((res) => {
                if (res.errcode == 0) {
                    var data=res.data.yjQmpMsWeighbridgematerial;
                    this.formData=res.data.yjQmpMsWeighbridgematerial;
                    this.enterPhoto=[data.entryPhoto1,data.entryPhoto2,data.entryPhoto3,data.entryPhoto4]
                    this.leavePhoto=[data.leavePhoto1,data.leavePhoto2,data.leavePhoto3,data.leavePhoto4]
                
                }else {
                   
                    this.$message.error(res.msg);
                }
            });
        },

    },
};